<%--
  Created by IntelliJ IDEA.
  User: Feilong
  Date: 2018/8/12
  Time: 22:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript" src="../dist/jquery/jquery-1.8.3.js"></script>
<head>
    <title>书籍智能查询</title>
    <style type="text/css">
        #id-form-center{
            padding: 20px 40%;
        }
    </style>
</head>
<body>
<%--<-center">
    <s:form action="queryBook" method="POST">
        <s:textfield name="keywords" />
        <s:radio name="radioValue"
                 list="#{'bname':'书籍名11','bauthor':'作者22','bpress':'出版社33'}" listKey="key" listValue="value"/>
        <s:submit type="input" value="查询" name=""/>
        <s:reset value="重置"/>
    </s:form>
</div>--%>

<div id="id-form-center">
    <form name="queryBook" method="post">
        <input type="text" name="keywords"><br>
        <input type="radio" name="radioValue" value="queryByBname">书籍名1
        <input type="radio" name="radioValue" value="queryByBauthor">作者2
        <input type="radio" name="radioValue" value="queryByBpress">出版社3<br>
        <input type="reset" value="重置">
    </form>
    <table id="id-table-queryResult">

    </table>
    <hr>

</div>

<tabe id="id-table-querybook">

</tabe>
</body>
</html>
<script type="text/javascript">
    
    $(function () {
        $("input[name=radioValue]").click(function () {
            console.log('aaaaa');
            console.log('$("input[name=radioValue]").val()==1=='+$("input[name=radioValue]").val());
            console.log('$("input[name=keywords]").val()===1=='+$("input[name=keywords]").val());
            $.ajax({
                type:'post',
                url:'queryBook_'+$("input[name=radioValue]").val()+'.action',
                data:{
                    radioValue:$("input[name=radioValue]").val(),
                    keywords:$("input[name=keywords]").val(),
                },
                dataType:'json',
                success:function (data) {
                    console.log('bbbbb');
                    console.log('$("input[name=radioValue]").val()==2=='+$("input[name=radioValue]").val());
                    console.log('$("input[name=keywords]").val()===2=='+$("input[name=keywords]").val());
                    console.log(data);
                    console.log('长度=='+data.length);

                    var i=0;
                    $.each(data.list,function (index,obj) {
                        i=i+1;
                        console.log('==第 '+i+' 次 索引='
                            +index+'==='
                            +obj.bid+'==='
                            +obj.bname+'==='
                            +obj.bauthor+'==='
                            +obj.bpress+'==='
                            +obj.bprice+'==='
                            +obj.bcount+'==='
                            +obj.bpic+'==='
                        );
                    });

                }
            });
        });


    });
</script>
